POV-Ray : Newsgroups : povray.newusers : Lighting : Re: Lighting Server Time
30 Jul 2024 20:18:41 EDT (-0400)
  Re: Lighting  
From: Christopher James Huff
Date: 6 Feb 2004 13:34:04
Message: <cjameshuff-E67770.13341606022004@news.povray.org>
In article <4023cb35$1@news.povray.org>,
 "Dan P" <dan### [at] yahoocom> wrote:

> That's interesting -- I never use phong, but I would think they are the same
> thing, aren't they Chris? Maybe people who make the best scenes use phong
> because they are long-time users of POV-ray and phong used to be specular
> (or, was it, I'm not sure -- I don't have POV-ray at work).
> 
> This is a really good question. If anybody will know the answer, it will
> definitely be Chris; he's got the internals down and then some :-)

Despite my lack of post-college experience?
Okay, here it goes:
They are definitely not the same thing. Phong is the older shading 
method, and is very simple mathematically, computationally cheap, but 
not very accurate. In terms of POV code, the equation used is:

phongAmt*surfaceColor*pow(vdot(reflectionVector, lightVector), phongSize)

The reflection vector is the direction a reflected ray would go, the 
light vector is a vector pointing towards the light source. When the two 
line up, their dot product equals 1, and the highlight is the brightest 
where you would see a reflection of the light. When the two are 
perpendicular, the result is 0, and the highlight drops to nothing.

Specular uses a different and more physically accurate highlight 
function:

specularAmt*surfaceColor*pow(vdot(halfPt, normal), 1/roughness)

where halfPt is halfway between the ray origin and the light source. It 
is also brightest at the points where the reflection of the light source 
would be visible, but the falloff is different.

If metallic is specified, a Fresnel reflection function is used. It 
takes the intensity part of the above calculation and adds some 
additional calculations based on the angle of the surface to the light:

specIntensity = specularAmt*pow(vdot(halfPt, normal), 1/roughness)
F = abs(acos(vdot(normal, lightVector))/(pi/2))
F = 0.014567225/sqr(F - 1.12) - 0.011612903

F is then clamped to the range 0-1, and the final highlight color is:

lightColor*specIntensity*(1 + metallicAmt*(1 - F)*(surfaceColor - 1))

This function is based on actual measurements of real-world surfaces, 
and is the most realistic highlight for metallic objects.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.